import {
	yzQueryPageList,
	getYzOrderDetailPage,
	getYzStatusOrder,
	agentServerLogin,
	agentRegister,
	agentStaffServerLogin,
	agentStaffRegister,
	getAgentCode,
	staffBindAgent,
	getLeader,
	getStaffList,
	unBindStaff,
	getFansList,
	getFansPageList,
	getFansIsCustomer,
	getFansPageLists,
	getTodoList,
	staffPass,
	staffNotPass,
	saveAppointOrder,
	updateSaveAppointOrder,
	getAppointList,
	getShopsList,
	getAgentCode2,
	getEmpList,
	getShopsShowPic,
	getAgentByTeamNo,
	deleteListAppointOrder
} from '../../api/agent.js'

export default {
	state: {
		agentInfo: {},
		agentStaffInfo: {},
		agentFansCache: {},
		agentTodoCache: {}
	},
	mutations: {
		setAgentInfo(state, payload) {
			state.agentInfo = payload
		},
		setAgentStaffInfo(state, payload) {
			state.agentStaffInfo = payload
		},
		setAgentFansCache(state, payload) {
			state.agentFansCache = payload
		},
		setAgentTodoCache(state, payload) {
			state.agentTodoCache = payload
		}
	},
	getters: {
		getAgentInfo(state) {
			return state.agentInfo
		}
	},
	actions: {
		yzQueryPageList({}, payload) {
			return new Promise((resolve, reject) => {
				yzQueryPageList(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getYzOrderDetailPage({}, payload) {
			return new Promise((resolve, reject) => {
				getYzOrderDetailPage(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getYzStatusOrder({}, payload) {
			return new Promise((resolve, reject) => {
				getYzStatusOrder(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		agentServerLogin({}, payload) {
			return new Promise((resolve, reject) => {
				agentServerLogin(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		agentRegister({}, payload) {
			return new Promise((resolve, reject) => {
				agentRegister(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		agentStaffServerLogin({}, payload) {
			return new Promise((resolve, reject) => {
				agentStaffServerLogin(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		agentStaffRegister({}, payload) {
			return new Promise((resolve, reject) => {
				agentStaffRegister(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getAgentCode({}, payload) {
			return new Promise((resolve, reject) => {
				getAgentCode(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		staffBindAgent({}, payload) {
			return new Promise((resolve, reject) => {
				staffBindAgent(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getLeader({}, payload) {
			return new Promise((resolve, reject) => {
				getLeader(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getStaffList({}, payload) {
			return new Promise((resolve, reject) => {
				getStaffList(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		unBindStaff({}, payload) {
			return new Promise((resolve, reject) => {
				unBindStaff(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getFansList({}, payload) {
			return new Promise((resolve, reject) => {
				getFansList(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		// 分页查询粉丝
		getFansPageList({},payload){
			return new Promise((resolve,reject)=>{
				getFansPageList(payload).then(res=>{
					resolve(res)
				}).catch(err=>{
					reject(err)
				})
			})
		},
		getFansPageLists({},payload){
			return new Promise((resolve,reject)=>{
				getFansPageLists(payload).then(res=>{
					resolve(res)
				}).catch(err=>{
					reject(err)
				})
			})
		},
		// 粉丝是否为客户
		getFansIsCustomer({},payload){
			return new Promise((resolve,reject)=>{
				getFansIsCustomer(payload).then(res=>{
					resolve(res)
				}).catch(err=>{
					reject(err)
				})
			})
		},
		getTodoList({}, payload) {
			return new Promise((resolve, reject) => {
				getTodoList(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		staffPass({}, payload) {
			return new Promise((resolve, reject) => {
				staffPass(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		staffNotPass({}, payload) {
			return new Promise((resolve, reject) => {
				staffNotPass(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		// 提交保存表单
		saveAppointOrder({}, payload) {
			return new Promise((resolve, reject) => {
				saveAppointOrder(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		// 实时更新表单
		updateSaveAppointOrder({}, payload) {
			return new Promise((resolve, reject) => {
				updateSaveAppointOrder(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		deleteListAppointOrder({}, payload) {
			return new Promise((resolve, reject) => {
				deleteListAppointOrder(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		// 删除list的内容
		getAppointList({}, payload) {
			return new Promise((resolve, reject) => {
				getAppointList(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getShopsList({}, payload) {
			return new Promise((resolve, reject) => {
				getShopsList(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getAgentCode2({}, payload) {
			return new Promise((resolve, reject) => {
				getAgentCode2(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getEmpList({
			rootState
		}, payload) {
			return new Promise((resolve, reject) => {
				getEmpList({
					teamNo: rootState.user.userInfo.teamNo
				}).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getShopsShowPic({}, payload) {
			return new Promise((resolve, reject) => {
				getShopsShowPic(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
		getAgentByTeamNo({}, payload) {
			return new Promise((resolve, reject) => {
				getAgentByTeamNo(payload).then(res => {
					resolve(res)
				}).catch(err => {
					reject(err)
				})
			})
		},
	},
	namespaced: true
}
